package com.cslg.ac.demo.entity.user;

import com.cslg.ac.demo.util.string.StringUtil;

public class User {
    int id;
    String userName;
    String password;
    String salt;
    int userType;

    public User() {
    }
    public boolean registerValid(int userNameLength,int passwordLength) {
        if (StringUtil.haveNullOrEmpty(userName, password)) {
            return false;
        }
        if (!StringUtil.allNumber(userName) || userName.length() != userNameLength) {
            return false;
        }
        if (!StringUtil.allNumber(userName)) {
            return false;
        }
        if (StringUtil.lengthAbove(password, passwordLength)) {
            return false;
        }
        if (userType != 0 && userType != 1) {
            return false;
        }
        if(password.contains(" ")){
            return false;
        }
        return true;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }


    public int getUserType() {
        return userType;
    }

    public void setUserType(int userType) {
        this.userType = userType;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", salt='" + salt + '\'' +
                ", userType=" + userType +
                '}';
    }
}
